package com.mooc.lib_user.ui.login

import com.mooc.lib_network.entity.BaseRepository
import com.mooc.lib_network.entity.NetResult
import com.mooc.lib_network.entity.RetrofitSingle
import com.mooc.lib_user.ApiService
import com.mooc.lib_user.model.LoginEntity

class LoginRepo : BaseRepository() {

    suspend fun login(avatar : String,description:String,
                      expires_time:Long,followCount:Int,
                      likeCount:Int,name:String,
                      qqOpenId:String,topCommentCount:Int):NetResult<LoginEntity>{
        return requestCall ( call={requestLogin(avatar, description, expires_time,
            followCount, likeCount, name, qqOpenId, topCommentCount)} )
    }

    suspend fun requestLogin(avatar : String,description:String,
                             expires_time:Long,followCount:Int,
                             likeCount:Int,name:String,
                             qqOpenId:String,topCommentCount:Int):NetResult<LoginEntity>{
        return handlerResponse(
            RetrofitSingle.instance().getRetrofit()
                .create(ApiService::class.java)
                .requestInsertUser(avatar, description, expires_time, followCount, likeCount, name, qqOpenId, topCommentCount)
        )
    }

}